﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Splitting
{
    class Node
    {
        private static int nextId = 0;

        public int ID { get; private set; }

        public Node Left { get; private set; }
        public Node Right { get; private set; }

        public bool IsLeaf { get { return Left == null && Right == null; } }

        public Node()
        {
            ID = nextId++;
            Left = null;
            Right = null;
            Console.WriteLine(string.Format("New node created: {0}", ID));
        }

        public void Report()
        {
            Console.WriteLine(string.Format("Node {0} is {1}a leaf", ID, IsLeaf ? string.Empty : "not "));
        }

        public void Sprout()
        {
            Left = new Node();
            Right = new Node();
        }

    }
}
